Ext.namespace('VAS');

VAS.AdvancedSearchDateField = Ext.extend(Ext.form.CompositeField,{
	initComponent : function() {
	 	var _this=this;
	 	
	 	thisConfig={
	 		width :_this.width,
	        fieldLabel : _this.fieldLabel,
	        readOnly : _this.readOnly,
	        items : [
		        {
				   id	: _this.name+'_gt',
	               name : _this.name+'_gt',
	               xtype: 'datefield',
	               format:'Y-m-d'
		        }
		        ,
		        {
					xtype: 'label',
					value: '<font size=2 >至</font>',
					hideLabel       : true
					,width: 32
					,style :{
						paddingLeft : '10px'
					}
		        },
		        {
		           id	: _this.name+'_lt',
	               name : _this.name+'_lt',
	               xtype: 'datefield',
				   format:'Y-m-d'
		        }
	        ]
	      };
	 	
		 Ext.apply(this, thisConfig);
		 Ext.apply(this.initialConfig, thisConfig);
		 VAS.AdvancedSearchDateField.superclass.initComponent.apply(this,arguments);
	}
	,onRender : function(ct,position){
		var _this=this;
		VAS.AdvancedSearchDateField.superclass.onRender.call(this, ct, position);	
		var gt = Ext.getCmp(_this.name+'_gt');
	 	var it = Ext.getCmp(_this.name+'_lt');
	 	gt.on('focus',function(textfield,event){
	 		if(it.getValue() != ''){
				gt.maxValue = it.getValue();
	 		}
	 	});
	 	it.on('focus',function(){
	 		if(gt.getValue() != ''){
				it.minValue = gt.getValue();
	 		}
	 	});
	}

});

Ext.reg('advancedSearch_datefield',VAS.AdvancedSearchDateField);